package hasthi.tools;

import hasthi.common.Utils;

import org.apache.log4j.PatternLayout;
import org.apache.log4j.spi.LoggingEvent;

public class HasthiLayout extends PatternLayout{
    public HasthiLayout() {
        super();
        hostName = new StringBuffer().append("[").append(Utils.getLocalHost()).append("]").toString();
    }

    public HasthiLayout(String pattern) {
        super(pattern);
        hostName = new StringBuffer().append("[").append(Utils.getLocalHost()).append("]").toString();
    }

    private String hostName;

    @Override
    public String format(LoggingEvent event) {
        return new StringBuffer().append(hostName)
            .append(super.format(event)).toString();
    }
}
